package xin.marcher.wind.process.controller.tradeplatform;


import org.springframework.web.bind.annotation.*;
import xin.marcher.framework.common.web.response.BaseResult;
import xin.marcher.wind.process.domain.request.TradePlatformBizRequest;
import xin.marcher.wind.process.domain.vo.TradePlatformBizVO;
import xin.marcher.wind.process.dto.BizProcessArrangeDTO;
import xin.marcher.wind.process.service.TradePlatformBizService;

import javax.annotation.Resource;

/**
 * 交易平台接入业务线管理 前端控制器
 *
 */
@RestController
@RequestMapping("/trade-platform/biz")
public class TradePlatformBizController {

    @Resource
    private TradePlatformBizService tradePlatformBizService;

    /**
     * 业务线发布流程编排
     * @param
     * @return 响应
     */
    @GetMapping("/release")
    public BaseResult<Boolean> release(String bizId) {
        tradePlatformBizService.release(bizId);
        return BaseResult.success(true);
    }

    /**
     * 查询业务线流程编排
     * @param bizId
     * @return 响应
     */
    @GetMapping("/arrange")
    public BaseResult<BizProcessArrangeDTO> getBizProcessArrange(String bizId) {
        return BaseResult.success(tradePlatformBizService.getBizProcessArrange(bizId));
    }

    /**
     * 新增一个接入业务线
     * @param tradePlatformBizRequest
     * @return
     */
    @PostMapping("/biz")
    public TradePlatformBizVO addBiz(@RequestBody TradePlatformBizRequest tradePlatformBizRequest) {
        return tradePlatformBizService.addBiz(tradePlatformBizRequest);
    }

    /**
     * 查询接入业务线
     * @param bizId
     * @return
     */
    @GetMapping("/biz/{bizId}")
    public TradePlatformBizVO getBiz(@PathVariable("bizId") String bizId) {
        return tradePlatformBizService.getBiz(bizId);
    }

    /**
     * 修改接入业务线
     * @param tradePlatformBizRequest
     * @return
     */
    @PutMapping("/biz")
    public TradePlatformBizVO editBiz(@RequestBody TradePlatformBizRequest tradePlatformBizRequest) {
        return tradePlatformBizService.editBiz(tradePlatformBizRequest);
    }

    /**
     * 删除一个接入业务线
     * @param bizId
     * @return
     */
    @DeleteMapping("/biz/{bizId}")
    public Boolean deleteBiz(@PathVariable("bizId") String bizId) {
        return tradePlatformBizService.deleteBiz(bizId);
    }

}
